package org.linlinjava.litemall.admin.web.distribution;

import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.DisMemberInfo;
import org.linlinjava.litemall.db.domain.DisProfitRecord;
import org.linlinjava.litemall.db.service.distribution.DisMemberInfoService;
import org.linlinjava.litemall.db.service.distribution.DisProfitRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 利润分成
 *
 * @author huangpu
 * @Date 2018-04-06 12:19:23
 */
@Controller
@RequestMapping("/admin/disProfitRecord")
public class DisProfitRecordController extends BaseController {

    @Autowired
    DisProfitRecordService disProfitRecordService;
    @Autowired
    DisMemberInfoService disMemberInfoService;




    /**
     * 获取交易列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@LoginAdmin Integer adminId,
                       String username,  String getUserId, String setUserId,
                       @RequestParam(value = "page", defaultValue = "1") Integer page,
                       @RequestParam(value = "limit", defaultValue = "10") Integer limit
                      ) {
        if (adminId == null) {
            return ResponseUtil.fail401();
        }
        List<DisProfitRecord> memList = disProfitRecordService.querySelective(username, getUserId, setUserId, page, limit);
        int total = disProfitRecordService.countSeletive(username, setUserId, getUserId, page, limit);
        Map<String, Object> data = new HashMap<>();
        data.put("total", total);
        data.put("items", memList);
        return ResponseUtil.ok(data);
    }



    /**
     * 删除交易
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete() {
        return null;
    }


    /**
     * 修改交易
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update() {
        return null;
    }

    /**
     * 交易详情
     */
    @RequestMapping(value = "/detail")
    @ResponseBody
    public Object detail() {
        return null;
    }
}
